package net.maku.module.car.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import net.maku.framework.common.utils.PageResult;
import net.maku.framework.common.utils.Result;
import net.maku.module.car.convert.CarConvert;
import net.maku.module.car.entity.CarEntity;
import net.maku.module.car.service.CarService;
import net.maku.module.car.vo.CarVO;
import net.maku.newbase.NewBaseController;
import net.maku.newbase.NewQuery;
import net.maku.newbase.PageParam;

import org.springframework.web.bind.annotation.*;

/**
* 业务_车辆
*
* @author    
*/
@RestController
@RequestMapping("nb/car")
@Tag(name="业务_车辆")
@AllArgsConstructor
public class CarController extends NewBaseController<CarService, CarEntity> {

    @GetMapping("page")
    @Operation(summary = "分页")
    public Result<PageResult<CarVO>> page(PageParam page, NewQuery query){
        LambdaQueryWrapper<CarEntity> select = new LambdaQueryWrapper<>();

        IPage<CarEntity> iPage = entityService.page(page.b(), select);
        return Result.ok(new PageResult<>(CarConvert.INSTANCE.convertList(iPage.getRecords()), iPage.getTotal()));
    }

}